//
//  SearchProducts_Single_CCell.swift
//  MikerShop
//
//  Created by eme on 2016/11/29.
//  Copyright © 2016年 eme. All rights reserved.
//

///小图显示商品搜索的cell
import UIKit
import RickonCore
import BrandonCore

class SearchProducts_Single_CCell: UICollectionViewCell {
    /// 品牌商
    @IBOutlet weak var brname_Lb: UILabel!
    /// 商品名称
    @IBOutlet weak var pdname_Lb: UILabel!
    /// 起批量
    @IBOutlet weak var munit_Lb: UILabel!
    /// 销量
    @IBOutlet weak var salecount_Lb: UILabel!
    /// 进货价
    @IBOutlet weak var minshprice_Lb: UILabel!
    
    @IBOutlet weak var jinPriceImg_V: UIImageView!
    
    /// 利润
    @IBOutlet weak var grossprofit_Lb: UILabel!
    @IBOutlet weak var profit_V: UIView!
    ///商品图片
    @IBOutlet weak var img1_ImgV: UIImageView!
    @IBOutlet weak var sellOut_ImgV: UIImageView!
    
    @IBOutlet weak var separate_Line_V: UIView!
    
    var item :ProductlistModel?{
        didSet{
            if let item = self.item {
                self.brname_Lb.text = item.brname
                self.pdname_Lb.text = item.pdname
                self.munit_Lb.text = "\(item.munit)起批"
                self.salecount_Lb.text = "已售\(item.salecount)件"
                self.jinPriceImg_V.image = UIImage(named: AppData.getPriceImgName(), in: RobbCore.bundle, compatibleWith: nil)
                self.minshprice_Lb.text = AppData.getFinalShowPrice(jinPrice: item.minshprice, lingPrice: item.bdprice).getPriceStr()
                self.grossprofit_Lb.text = "利:\(item.grossprofit.getPriceStr())"
                self.img1_ImgV.setUrlImage(item.img1)
                if item.stock == 0 {
                    self.sellOut_ImgV.isHidden = false
                    self.sellOut_ImgV.image = UIImage(named: "sellout", in: RobbCore.bundle, compatibleWith: nil)
                }else{
                    self.sellOut_ImgV.isHidden = true
                }
                if  case .audited = AppData.appState {
                    self.profit_V.isHidden = false
                    /// 1 表示商品 0 表示是仪器等非商品类型
                    self.profit_V.isHidden = item.ptisproduct != "1"
                }else{
                    self.profit_V.isHidden = true
                }
            }
        }
    }
    
    override func awakeFromNib() {
        self.brname_Lb.text = "  "
        self.pdname_Lb.text = "  "
        self.munit_Lb.text = ""
        self.brname_Lb.text = ""
        self.salecount_Lb.text = "已售0件"
        self.minshprice_Lb.text = 0.00.getPriceStr()
        self.grossprofit_Lb.text = "利:\(0.00.getPriceStr())"
        self.img1_ImgV.image = UIImage(named: "product-placeholder")
        self.profit_V.changeBorderColor(Theme.v.product_li,cornerRadius: 1)
        self.separate_Line_V.backgroundColor = Theme.v.separate_Line
        
        self.brname_Lb.normal_fontSize(13)
        self.pdname_Lb.normal_fontSize(14)
        self.munit_Lb.normal_fontSize(13)
        self.salecount_Lb.normal_fontSize(13)
        self.minshprice_Lb.bold_fontSize(14)
        self.grossprofit_Lb.normal_fontSize(11)
    }
}
